package pl.cezary.butler.walili;

import java.util.Arrays;
import java.util.logging.Logger;
import pl.cezary.butler.walili.client.ClientApp;
import pl.cezary.butler.walili.client.DownloaderApp;

/**
 * Hello world!
 *
 */
public class App {
    
    private static final Logger log = Logger.getLogger(App.class.getName());

    private static void setupLookAndFeel() {
        try {
            javax.swing.UIManager.LookAndFeelInfo[] installedLookAndFeels = javax.swing.UIManager.getInstalledLookAndFeels();
            for (int idx = 0; idx < installedLookAndFeels.length; idx++) {
                if ("Nimbus".equals(installedLookAndFeels[idx].getName())) {
                    javax.swing.UIManager.setLookAndFeel(installedLookAndFeels[idx].getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            log.log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            log.log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            log.log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            log.log(java.util.logging.Level.SEVERE, null, ex);
        }
    }

    public static void main(String[] args) {
        setupLookAndFeel();
        if (args.length > 0) {
            final String first = args[0];
            if ("-D".equals(first)) {
                DownloaderApp.main(Arrays.copyOfRange(args, 1, args.length));
            } else if ("-C".equals(first)) {
                ClientApp.main(Arrays.copyOfRange(args, 1, args.length));

            }
        } else {
            ClientApp.main(args);
        }
    }
}
